using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TouchTriggerSource : MonoBehaviour
{
    public PlayerElement element;
    public Player_FSM PlayerFsm;
    public void switchElement()
    {
        PlayerFsm.SwitchElement(element);
    }
    private void OnTriggerStay2D(Collider2D collider)
    {
        if (collider.tag == "Player")
        {
            if(PlayerFsm.PreIsTouch)
            {
                PlayerFsm.IsTouch = false;
                return;
            }
            else
            {
                PlayerFsm.PreIsTouch = true;
                if (PlayerFsm.currentEle != element)
                {
                    PlayerFsm.IsTouch = true;
                    switchElement();
                }
            }
        }
    }
    private void OnTriggerExit2D(Collider2D collider)
    {
        PlayerFsm.PreIsTouch = false;
    }
}
